import {HostListener, ElementRef,Directive,Input,Output} from "@angular/core";

@Directive({
  selector:"[input-trim]"
})
class InputTrimDirective{

	@Input()
	input:string;
	el:any;
	constructor(/**访问 DOM 元素*/el:any){
		this.el=el;
	// el.nativeElement.style.backgroundColor="green";
	}
	@HostListener("keyup",["$event.target"])
	keyupFun(evt:any) {
		if (evt.value) {
		 this.el.nativeElement.value = evt.value.trim();
		}
	}
}

export {InputTrimDirective};